package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.CustomerLost;
import cn.wolfcode.crm.mapper.CustomerLostMapper;
import cn.wolfcode.crm.page.PageResult;
import cn.wolfcode.crm.query.CustomerLostQueryObject;
import cn.wolfcode.crm.service.ICustomerLostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerLostServiceImpl implements ICustomerLostService{

    @Autowired
    private CustomerLostMapper customerLostMapper;

    public List<CustomerLost> selectAll() {
        return customerLostMapper.selectAll();
    }


    public PageResult query(CustomerLostQueryObject qo) {

        int totalCount = customerLostMapper.queryForCount(qo);
        if(totalCount == 0){
            return new PageResult();
        }
        List<CustomerLost> list = customerLostMapper.queryForList(qo);
        return new PageResult(totalCount,list);
    }

    public void updateByPrimaryKey(CustomerLost customerLost) {
        customerLostMapper.updateByPrimaryKey(customerLost);
    }

    public void lost(CustomerLost customerLost) {
        customerLostMapper.insert(customerLost);
    }

}
